package com.aj.controller;

import com.aj.Interface.SetmealService;
import com.aj.common.MessageConstant;
import com.aj.pojo.CheckItem;
import com.aj.pojo.Setmeal;
import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.JedisPool;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Reference
    private SetmealService  setmealService ;



    @RequestMapping("/findById")
    public Result  findById(Integer id) {
        try {
            JSONObject jsonObject = setmealService.findById(id);

            return new Result(true,MessageConstant.QUERY_SETMEAL_SUCCESS,jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.QUERY_SETMEAL_FAIL);
        }
    }


    @RequestMapping("/getSetmeal")
    public Result getSetmeal() {
        try {
            JSONArray setmealList = setmealService.findAll();
            return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS,setmealList);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.GET_SETMEAL_LIST_FAIL);
        }
    }
}
